package com.yzx.springbootjpa;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 用户服务数据接口类
 *
 * @author 杨高超
 * @since 2018-03-12
 */


/**
 * 用户服务数据接口类
 *
 * @author 杨高超
 * @since 2018-03-12
 */

@Repository
public interface UserDao extends JpaRepository<UserDO, Long> {
   //多属性查询接口
    UserDO findByAccount(String account);

    //自定义属性查询接口
    @Query("SELECT O FROM UserDO O WHERE O.name = :name1  OR O.name = :name2 ")
    List<UserDO> findTwoName(@Param("name1") String name1, @Param("name2") String name2);

    //原生sql语句查询
    @Query(nativeQuery = true, value = "SELECT * FROM AUTH_USER WHERE name = :name1  OR name = :name2 ")
    List<UserDO> findSQL(@Param("name1") String name1, @Param("name2") String name2);
}

